<?php error_reporting(E_ALL);
$params=array($_GET['site_page']);
$page = $shopObj->fetch_one('SELECT * FROM site_pages WHERE page_slug=?',$params);

?>

<link rel="stylesheet" href="<?php echo SERVER_PATH; ?>/uploadify/uploadify.css">

<div class="tabbable">
	<ul class="nav nav-tabs" id="site_page_tabs">
		<li class='active' >
			<a data-toggle="tab" href="#description">
				Description
			</a>
		</li>
		<?php 
		if($page['show_pictures']==1){
			?>
			<li>
				<a data-toggle="tab" href="#pictures">
					Pictures
				</a>
			</li>
			<?php 
		}
		if($page['show_carousel']==1){
			?>
			<li>
				<a data-toggle="tab" href="#carousel">
					Carousel
				</a>
			</li>
			<?php 
		}
		?>
	</ul>	
	<div class="tab-content">
		<!-- data about the page -->
		<div id='description' class="tab-pane active">

			<!-- info about what to do -->
			<div class='span3'>
				<ul class="unstyled spaced2">
					<li>
						<i class="icon-circle green"></i>
						introduce numele pagini
					</li>
					<li>
						<i class="icon-circle green"></i>
						tagurile de meta description si meta keyword nu sunt obligatorii
					</li>
				
				</ul>
			</div>	
			<!-- tabs for active languages -->
			<form id='page_descriptions' name='page_descriptions' method='get' action=''>
				<div class="tabbable span9">
					<ul class="nav nav-tabs" id="site_page_description">
						<?php 
						$ii=0;
						foreach($available_lang as $value){
							if($ii==0){
								$active='active';
							}else{
								$active='';
							}
							echo '<li class="'.$active.'" >
							<a data-toggle="tab" href="#description_'.$value['id'].'">
							'.$value['abv'].'
							</a>
							</li>';
							$ii++;
						}
						?>
					</ul>


					<div class="tab-content" style='background-color:white'>				

						<?php
						$i=0;
						foreach($available_lang as $value){ 
							if($i==0){
								$active_tab='active';
							}else{
								$active_tab='';
							}
							$i++;
							$params=array($page['id'],$value['id']);
							$page_details=$shopObj->fetch_one("SELECT * FROM site_page_details WHERE site_page_id=? AND language_id=?",$params);

							?>
							<div id='description_<?php echo $value['id']; ?>' class='tab-pane <?php echo $active_tab; ?>'>
								<div class="control-group">
									<label class="control-label span2" for="page_title<?php echo $value['id'] ?>">Page title</label>
									<div class="controls span10">
										<input id="page_title<?php echo $value['id'] ?>" name='page_title<?php echo $value['id'] ?>' class='span5' type="text" placeholder="" value='<?php echo $page_details['name']; ?>'>
									</div>
								</div>
								<div class="control-group">
									<label class="control-label span2" for="meta_keyword<?php echo $value['id'] ?>">Meta keyword</label>
									<div class="controls span10">
										<input id="meta_keyword<?php echo $value['id'] ?>" name='meta_keyword<?php echo $value['id'] ?>' class='span5' type="text" placeholder="" value='<?php echo $page_details['meta_keywords']; ?>'>
									</div>
								</div>
								<br class='clear'/>
								<div class="control-group">
									<label class="control-label span2" for="meta_description<?php echo $value['id'] ?>" >Meta description</label>
									<div class="controls span10">
										<textarea id='meta_description<?php echo $value['id'] ?>' name='meta_description<?php echo $value['id'] ?>' class='span5'><?php echo $page_details['meta_description']; ?></textarea>
									</div>
								</div>
								<br class='clear'/>
								<?php if($page['has_description']==1){ ?>
								<div class="control-group">
									<label class="control-label span2" for="description">Description</label>
									<div class="controls span10">
										<div id="editor_<?php echo $value['id'];  ?>" class="wysiwyg-editor header-color-blue" contenteditable="true">
											<?php echo @$page_details['description']; ?>
										</div>
									</div>
								</div>
								<?php } ?>
								
							</div>

							<?php } ?>

						</div>
						<button class="btn btn-primary pull-right" onclick = 'save_page_details(<?php echo $page['id']; ?>);return false'>
							<i class="icon-save "></i>
							Save</button>
						</div>
					</form>

				</div>
				<?php 
				if($page['show_pictures']==1){
					?>
					<div id='pictures' class="tab-pane">
						<div class='span3'>
							<ul class="unstyled spaced2">
								<li>
									<i class="icon-circle green"></i>
									adauga poze pentru pagina ta
								</li>
								<li>
									<i class="icon-circle green"></i>
									apasa pe sterge ptr a sterge o poza
								</li>
								
								
							</ul>	
						</div>
						<div class='span9'>
							<input type="file" name="file_upload_pics" id="file_upload_pics" />
							<div id='page_pictures'>
								<?php 
									$pictures= $shopObj->fetch_result("SELECT  picture_files.name , picture_files.id FROM picture_files,site_page_pictures

																		WHERE  site_page_pictures.picture_id=picture_files.id AND site_page_pictures.site_page_id ='{$page['id']}'");
									foreach ($pictures as $key_pic => $value_pic) {
										echo "<div style='width:150px; margin-left:5px;text-align:center;float:left'>
												<div style='width:150px;height:150px;background:url(".SERVER_PATH."../shop/{$value_pic['name']}) center center no-repeat;background-size:150px auto'></div>
												
												<br class='clear'/>
												<button class='btn btn-mini btn-danger' style='margin-top:5px;margin-bottom:5px' onclick='delete_page_img(".$value_pic['id'].",this,".$page['id'].");'><i class='icon-trash '></i>Delete</button>
											  </div>";		
									}	
								?>
							</div>	
						</div>
					</div>
					<?php 
				}
				if($page['show_carousel']==1){
					?>
					<div id='carousel' class="tab-pane">
						<div class='span3'>
							<ul class="unstyled spaced2">
								<li>
									<i class="icon-circle green"></i>
									adauga poze pentru carousel dupa pagina
								</li>
								<li>
									<i class="icon-circle green"></i>
									este de preferat ca imaginea sa aiba rezolutia 960 X 335
								</li>
								<li>
									<i class="icon-circle green"></i>
									da click pe poza si completeaza informatiile de sub poze daca vrei sa apara un titlu un link sau un text pe poza respectiva
								</li>
							</ul>	
						</div>
						<div class='span9'>
							<input type="file" name="file_upload" id="file_upload" />
							<div class='carousel_container'>

								<?php 
								$carousels=$shopObj->fetch_result("SELECT * FROM carousel WHERE page_id={$page['id']}");
								foreach ($carousels as $key => $value) {
									echo '<div  style="margin-bottom:5px;margin-left:10px">
									<div class="span2" style="text-align:center;;margin-left:10px">';		
									echo "<div onclick='get_carousel_info(".$value['id'].",this);' style='margin-left:auto;margin-right:auto;cursor:pointer;width:108px;height:100px;background:url(".SERVER_PATH."../shop/images/{$value['picture']}) center center no-repeat;background-size:150px auto'></div>";						
									
									echo '<br class="clear"/>
									<button class="btn btn-mini btn-danger" style="margin-top:5px;margin-bottom:5px" onclick="delete_carousel_img('.$value['id'].',this);return false;"><i class="icon-trash "></i>Delete</button>
									</div>';
									
									echo "</div>";	
								}
								echo "</div>";
								echo '<div class="tabbable span10" style="margin-top:20px;">
									<ul class="nav nav-tabs">';
									$i=0;
									foreach ($available_lang as $key1 => $value1) {
										if($i==0){$active_list='active';}else{$active_list='';}
										echo "<li class='{$active_list}'> <a data-toggle='tab' href='#carousel5{$i}'>{$value1['abv']}</a></li>";
										$i++;
									}
									echo "</ul>
										<div class='tab-content' style='background-color:white'>";
										
										$i=0;
										foreach ($available_lang as $key2 => $value2) {
											if($i==0){$active_tab='active';}else{$active_tab='';}
											
											echo "<div id='carousel5{$i}' class='tab-pane {$active_tab}'>
													<div class='control-group'>
															<label class='control-label span2' >Title</label>
														<div class='controls span10'>
															<input class='span5' type='text' value='' placeholder='' id='title_{$value2['id']}' name='title_{$value2['id']}' onblur='update_carousel(\"title\",{$value2['id']},this.value,{$value2['id']})' >
														</div>
													</div>
													<div class='control-group'>
															<label class='control-label span2' for='page_title1'>Link</label>
														<div class='controls span10'>
															<input class='span5' type='text' value='' id='link_{$value2['id']}' name='link_{$value2['id']}' onblur='update_carousel(\"link\",{$value2['id']},this.value,{$value2['id']})'>
														</div>
													</div>
													<div class='control-group'>
															<label class='control-label span2' for='page_title1'>Text on image</label>
														<div class='controls span10'>
															<input class='span5' type='text' value='' name='description_carousel_{$value2['id']}' id='description_carousel_{$value2['id']}' onblur='update_carousel(\"description\",{$value2['id']},this.value,{$value2['id']})'>
														</div>
													</div>
												</div>";
												$i++;
										}
									

								?>

							</div>
							<button class="btn btn-primary pull-right" onclick="return false">
								<i class="icon-save "></i>
								Save
							</button>
						</div>	
					</div>
					<?php 
				}
				?>
			</div>
		</div>
		<input type='hidden' value="<?php echo $page['id']; ?>" name='page_id' id='page_id'>
